<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:py="http://genshi.edgewall.org/">
    <xi:include href="master.html" />

<?python
    from mnemoply.utils import format_currency, format_date
    from mnemoply.common_knowledge import month_captions
?>

<head>
    <title>Finance history</title>
</head>

<body>
    <div align="center">
        [ <a href="./">Back</a> ]<br />
        <h2>${obj.surname + " " + obj.forename}: <none py:strip="True">finance history</none></h2>
        <h3>${from_my}&ndash;${to_my}</h3>
    </div>

    ${ET(form.display())}

    <table class="maintable">
        <thead>
            <tr>
                <th align="center">Month</th>
                <th align="center">Year</th>
                <th>Operation type</th>
                <th py:for="g in period_groups" align="center" py:if="g is not None" colspan="1">${g.title}</th>
                <th py:for="g in period_groups" align="center" py:if="g is None" colspan="1">No-group</th>
            </tr>
        </thead>

        <tbody>
            <loop py:for="month_data in month_data_list" py:if="month_data.show" py:strip="True">
                <!--! charge -->
                <tr>
                    <td rowspan="2">${month_captions[month_data.my.month]}</td>
                    <td rowspan="2">${month_data.my.year}</td>
                    <td>Charges</td>

                    <td py:for="g in period_groups">
                        <span py:if="month_data.by_group[g].show" py:strip="True">
                            <span py:for="cr in month_data.by_group[g].charge">
                                ${format_currency(cr.amount)} (${cr.realHours} <none py:strip="True">hours</none>)<br/>
                            </span>
                        </span>
                    </td>
                </tr>
                <!--! payment -->
                <tr>
                    <td>Payments</td>
                    <td py:for="g in period_groups">
                        <span py:if="month_data.by_group[g].show" py:strip="True">
                            <span py:for="pr in month_data.by_group[g].payment">
                                ${format_currency(pr.amount)} (${format_date(pr.date)})<br/>
                            </span>
                        </span>
                    </td>
                </tr>
            </loop>

            <tr>
                <td colspan="3">Current state</td>
                <td py:for="g in period_groups" align="center">${format_currency(alltime_total_by_group[g])}</td>
            </tr>
        </tbody>
    </table>

    <span>Current balance: </span> <span>${format_currency(obj.cacheBalance)}</span>
</body>
</html>
